repl: migrate errors to internal/errors#17716
Conversation
|
It is failed at test/async-hooks/test-callback-error.js on my local environment, but master branch also fails. |
|
@kysnm Sounds like you may be experiencing #15985 on your local machine. If you do any troubleshooting and find information that may be useful, please put it in that issue! (And if you find a fix for the problem, please submit a pull request!) Otherwise, yes, that is most likely unrelated to the change here. |
|
Pinging @nodejs/tsc since this will need two TSC approvals. |
lib/repl.js
Outdated
|
|
||
| if (err && err.message === 'Script execution interrupted.') { | ||
| if (err && err.message === | ||
| errors.message('ERR_SCRIPT_EXECUTION_INTERRUPTED')) { |
There was a problem hiding this comment.
I think you can check if err.code === 'ERR_SCRIPT_EXECUTION_INTERRUPTED' here instead (which is kinda the point of this PR, the code instead of the message should be used to match a type of error)
| } | ||
|
|
||
| // Test ERR_SCRIPT_EXECUTION_INTERRUPTED | ||
| assert.strictEqual( |
There was a problem hiding this comment.
This test does not look particularly useful since the error message formatter does not take any parameters for this error.
| 'await timeout(100000)\r', | ||
| 'Thrown: Error: Script execution interrupted.', | ||
| 'Thrown: Error [ERR_SCRIPT_EXECUTION_INTERRUPTED]: ' + | ||
| errors.message('ERR_SCRIPT_EXECUTION_INTERRUPTED'), |
There was a problem hiding this comment.
Since we are actually testing the error message, we don't really need to generate it with errors.message, can you change this to match the actual error message instead?
|
There are several tests that do incomplete matches against this error message, those should be updated as well, not necessarily in this PR though. |
doc/api/errors.md
Outdated
| <a id="ERR_SCRIPT_EXECUTION_INTERRUPTED"></a> | ||
| ### ERR_SCRIPT_EXECUTION_INTERRUPTED | ||
|
|
||
| A script execution interrupted. |
There was a problem hiding this comment.
Can you elaborate a bit more on this? For example:
Script execution was interrupted by `SIGINT` (Ctrl+C).
|
I have fixed as you pointed out. Please review. |
|
Nit, just a suggestion, not a blocking objection: I think we should probably leave it at |
|
@Trott |
doc/api/errors.md
Outdated
| <a id="ERR_SCRIPT_EXECUTION_INTERRUPTED"></a> | ||
| ### ERR_SCRIPT_EXECUTION_INTERRUPTED | ||
|
|
||
| Script execution was interrupted by `SIGINT` (Ctrl+C). |
There was a problem hiding this comment.
I kind of agree with @Trott that this is not exactly accurate. Maybe here we should say (for example, when Ctrl+C was pressed) instead
lib/internal/errors.js
Outdated
| E('ERR_PARSE_HISTORY_DATA', 'Could not parse history data in %s'); | ||
| E('ERR_REQUIRE_ESM', 'Must use import to load ES Module: %s'); | ||
| E('ERR_SCRIPT_EXECUTION_INTERRUPTED', | ||
| 'Script execution was interrupted by `SIGINT` (Ctrl+C).'); |
There was a problem hiding this comment.
We probably don't need the part in the parentheses in the error message. The details should be in the docs.
|
@joyeecheung @Trott Fixed!! |
|
Previous CI was stopped. New CI: https://ci.nodejs.org/job/node-test-pull-request/12257/ |
|
Landing... |
|
Thank you for your contribution, landed in ab5a2ab. |
Refs: #17709
cc @jasnell @joyeecheung
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)
doc, errors, repl